-
Notifications
You must be signed in to change notification settings - Fork 1
chore(greenhouse): makes route search validation Zod v4–ready (filter by prefix before parse) and upgrade zod to v4 #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 515d61a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
taymoor89
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this zod update touches code as well let's add changeset to update patch version of the apps changed.
| /** | ||
| * Filters raw URL search params to only known keys and keys that start with any allowed prefix. | ||
| * Use this before Zod parsing when you need prefix-based catchall validation | ||
| * (Zod v4 no longer provides ctx.path in preprocess). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not mention the zod version changes - not important after merge
taymoor89
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM 👍
| /** | ||
| * Filters raw URL search params to only known keys and keys that start with any allowed prefix. | ||
| * Use this before Zod parsing when you need prefix-based catchall validation | ||
| * (Zod v4 no longer provides ctx.path in preprocess). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not mention the changes from zod 3 > 4.
| /** | ||
| * Filters raw URL search params to only known keys and keys that start with any allowed prefix. | ||
| * Use this before Zod parsing when you need prefix-based catchall validation | ||
| * (Zod v4 no longer provides ctx.path in preprocess). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would not mention changes from zod3 > 4
Summary
Route search validation no longer relies on Zod’s
ctx.pathinz.preprocess(removed in Zod v4). A small helper filters URL search params by known keys and allowed prefixes before parsing with Zod, so the same behavior works with Zod v3 and v4. Upgraded Zod from v3 to v4 (exact version 4.3.6).Changes Made
utils.ts), supernova (lib/utils.ts), doop (lib/helpers.ts), and greenhouse (lib/helpers.ts)./servicesand/vulnerabilitiesroutes to validate search via the helper + schema (no preprocess usingctx.path)./alertsroute to use the helper with ACTIVE_FILTERS_PREFIX and PAUSED_FILTERS_PREFIX./violationsroute to use the helper with ACTIVE_FILTERS_PREFIX./admin/plugin-presetsroute to use the helper with SELECTED_FILTER_PREFIX (Zod v4–compatible).getFiltersForUrlasRecord<string, string | string[]>and adjusted implementation so search param types align with the route schema.instanceof Errorand fallback for empty message) and in doop/supernova validate-search return values.ctx.path.Related Issues
Screenshots (if applicable)
none
Testing Instructions
pnpm ipnpm TASKChecklist
PR Manifesto
Review the PR Manifesto for best practises.